<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<!-- Content Header (Page header) -->
<section class="content-header" style="">
    <h1>
        项目负责管理
        <small>项目负责信息管理页面</small>
    </h1>
    <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> 主页</a></li>
        <li><a href="#"> 项目负责管理</a></li>
        <li class="active">项目负责信息管理页面</li>
    </ol>
</section>

<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <!-- /.box-header -->
                <div class="box-body">
                    <div id="toolbar">
                        <form class="form-inline" id="searchForm">
                            <div class="form-group">
                                <label for="searchprojectName">&nbsp;&nbsp;&nbsp;项目名</label>
                                <input type="text" class="form-control input-sm" name="projectName" id="searchprojectName" placeholder="请输入项目名">
                                <label for="searchcustomer">客户</label>
                                <input type="text" class="form-control input-sm" name="customer" id="searchcustomer" placeholder="请输入客户">
                                <label for="searchhead">负责人</label>
                                <input type="text" class="form-control input-sm" name="head" id="searchhead" placeholder="请输入负责人">
                                <label>&nbsp;&nbsp;&nbsp;是否已经完成:</label>
                                <div class="input-group">
                                    是<input type="radio"  name="isComplete" id="searchisComplete" value="1">
                                    否<input type="radio" name="isComplete" id="searchisComplete1" value="0" checked>
                                </div>
                                <br/>
                                <label for="searchreservation">开始时间</label>
                                <div class="input-group">
                                    <div class="input-group-addon">
                                        <i class="fa fa-calendar"></i>
                                    </div>
                                    <input type="text" class="form-control input-sm" id="searchreservation">
                                    <input type="hidden" name="strStartTime" id="searchstrStartTime">
                                    <input type="hidden" name="strEndTime" id="searchstrEndTime">
                                </div>
                                <label for="searchreservation1">结束时间</label>
                                <div class="input-group">
                                    <div class="input-group-addon">
                                        <i class="fa fa-calendar"></i>
                                    </div>
                                    <input type="text" class="form-control input-sm" id="searchreservation1"  name="searchreservation1" th:value="${searchreservation1}">
                                    <input type="hidden" name="streStartTime" id="searchstreStartTime" th:value="${searchstreStartTime}">
                                    <input type="hidden" name="streEndTime" id="searchstreEndTime" th:value="${searchstreEndTime}">
                                </div>
                                <div class="btn-group btn-group-sm">
                                    <button type="button" class="btn btn-default" onclick="txtclear();javascript:$('table').bootstrapTable('refresh', {silent: true});">
                                        <i class="glyphicon glyphicon-search"></i>
                                        查询
                                    </button>
                                    <button type="reset" class="btn btn-default" onclick="cej()">
                                        <i class="glyphicon glyphicon-trash"></i>
                                        清空
                                    </button>
                                </div>
                            </div>
                        </form>
                        <div class="btn-group btn-group-sm">
                            <!-- Provides extra visual weight and identifies the primary action in a set of buttons -->
                            <button shiro:hasPermission="projectmanagement:create" type="button" id="addBtn" class="btn btn-default"
                                    data-toggle="modal"
                                    data-target="#addModal"><i class="glyphicon glyphicon-plus"></i> 新增
                            </button>
                            <!-- Indicates caution should be taken with this action -->
                            <button shiro:hasPermission="projectmanagement:update" type="button" id="editBtn" class="btn btn-default"
                                    data-toggle="modal"
                                    data-target="#editModal"
                                    data-action="{type:'editable',form:'#editForm',table:'#table',after:'editAfter'}"
                                    disabled><i class="glyphicon glyphicon-edit"></i> 修改
                            </button>
                            <!-- Indicates a dangerous or potentially negative action -->
                            <button shiro:hasPermission="projectmanagement:delete" type="button" id="deleteBtn" class="btn btn-default" data-toggle="modal"
                                    data-target="#deleteModal"
                                    data-action="{type:'delete',form:'#deleteForm',idField:'id',table:'#table'}"
                                    disabled><i class="glyphicon glyphicon-remove"></i> 删除
                            </button>
                        </div>
                    </div>
                    <table id="table"></table>
                </div>
                <!-- /.box-body -->
            </div>
            <!-- /.box -->

        </div>
        <!-- /.col -->
    </div>
    <!-- /.row -->
</section>
<!-- /.content -->
<!-- add Modal -->
<div class="modal fade" id="addModal" tabindex="-1" role="dialog" aria-labelledby="addModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="addModalLabel">添加项目负责信息</h4>
            </div>
            <div class="modal-body">
                <form id="addForm">
                    <div class="form-group">
                        <label class="control-label" for="projectName"><span class="asterisk">*</span>项目名:</label>
                        <input id="projectName" type="text" class="form-control" name="projectName" placeholder="输入项目名" minlength="1" required>
                        <div class="help-block with-errors"></div>
                    </div>
                    <div class="form-group">
                        <label class="control-label" for="strStartTime"><span class="asterisk">*</span>开始时间:</label>
                        <input type="text" class="form-control" name="strStartTime"  id="strStartTime" required>
                        <div class="help-block with-errors"></div>
                    </div>
                    <div class="form-group">
                        <label class="control-label" for="strEndTime"><span class="asterisk">*</span>结束时间:</label>
                        <input type="text" class="form-control" name="strEndTime"  id="strEndTime" required>
                        <div class="help-block with-errors"></div>
                    </div>
                    <div class="form-group">
                        <label class="control-label" for="customer"><span class="asterisk">*</span>客户:</label>
                        <input id="customer" type="text" class="form-control" name="customer" placeholder="输入客户" minlength="1" required>
                        <div class="help-block with-errors"></div>
                    </div>
                    <div class="form-group">
                        <label class="control-label" for="head"><span class="asterisk">*</span>负责人:</label>
                        <input id="head" type="text" class="form-control" name="head" placeholder="输入负责人" minlength="1" required>
                        <div class="help-block with-errors"></div>
                    </div>
                    <div class="form-group">
                        <label class="control-label" for="participants"><span class="asterisk">*</span>参与人员:</label>
                        <textarea id="participants" name="participants" class="form-control" cols="50" rows="3" placeholder="输入参与人员" required></textarea>
                        <div class="help-block with-errors"></div>
                    </div>
                    <div class="form-group">
                        <label class="control-label" ><span class="asterisk">*</span>是否已经完成:</label>
                        是<input type="radio"  name="isComplete" id="isComplete" value="1">
                        否<input type="radio" name="isComplete" id="isComplete1" value="0" checked>
                        <div class="help-block with-errors"></div>
                    </div>
                    <div class="form-group">
                        <label class="control-label" for="remark">备注:</label>
                        <textarea id="remark" name="remark" class="form-control" cols="100" rows="5" placeholder="输入备注"></textarea>
                        <div class="help-block with-errors"></div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="submit" form="addForm" class="btn btn-primary"
                        data-action="{type:'submit',form:'#addForm',url:'@{/projectmanagement/add}',after:'$.myAction.refreshTable'}">
                    确定
                </button>
            </div>
        </div>
    </div>
</div>
<!-- edit Modal -->
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="editModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="editModalLabel">修改项目负责信息</h4>
            </div>
            <div class="modal-body">
                <form id="editForm">
                    <div class="form-group">
                        <input id="editid" type="hidden" class="form-control" name="id" placeholder="输入项目名" minlength="1">
                        <label class="control-label" for="editprojectName"><span class="asterisk">*</span>项目名:</label>
                        <input id="editprojectName" type="text" class="form-control" name="projectName" placeholder="输入项目名" minlength="1" required>
                        <div class="help-block with-errors"></div>
                    </div>
                    <div class="form-group">
                        <label class="control-label" for="editstrStartTime"><span class="asterisk">*</span>开始时间:</label>
                        <input type="text" class="form-control" name="strStartTime"  id="editstrStartTime" required>
                        <div class="help-block with-errors"></div>
                    </div>
                    <div class="form-group">
                        <label class="control-label" for="editstrEndTime"><span class="asterisk">*</span>结束时间:</label>
                        <input type="text" class="form-control" name="strEndTime"  id="editstrEndTime" required>
                        <div class="help-block with-errors"></div>
                    </div>
                    <div class="form-group">
                        <label class="control-label" for="editcustomer"><span class="asterisk">*</span>客户:</label>
                        <input id="editcustomer" type="text" class="form-control" name="customer" placeholder="输入客户" minlength="1" required>
                        <div class="help-block with-errors"></div>
                    </div>
                    <div class="form-group">
                        <label class="control-label" for="edithead"><span class="asterisk">*</span>负责人:</label>
                        <input id="edithead" type="text" class="form-control" name="head" placeholder="输入负责人" minlength="1" required>
                        <div class="help-block with-errors"></div>
                    </div>
                    <div class="form-group">
                        <label class="control-label" for="editparticipants"><span class="asterisk">*</span>参与人员:</label>
                        <textarea id="editparticipants" name="participants" class="form-control" cols="50" rows="3" placeholder="输入参与人员" required></textarea>
                        <div class="help-block with-errors"></div>
                    </div>
                    <div class="form-group">
                        <label class="control-label" ><span class="asterisk">*</span>是否已经完成:</label>
                        是<input type="radio"  name="isComplete" id="editisComplete" value="1">
                        否<input type="radio" name="isComplete" id="editisComplete1" value="0">
                        <div class="help-block with-errors"></div>
                    </div>
                    <div class="form-group">
                        <label class="control-label" for="editremark">备注:</label>
                        <textarea id="editremark" name="remark" class="form-control" cols="100" rows="5" placeholder="输入备注"></textarea>
                        <div class="help-block with-errors"></div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="submit" form="editForm" class="btn btn-primary"
                        data-action="{type:'submit',form:'#editForm',url:'@{/projectmanagement/update}',after:'$.myAction.refreshTable'}">
                    确定
                </button>
            </div>
        </div>
    </div>
</div>

<!-- details Modal -->
<div class="modal fade" id="detailsModal" tabindex="-1" role="dialog" aria-labelledby="detailsModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="detailsModalLabel">项目负责信息详情</h4>
            </div>
            <div class="modal-body">
                <form id="detailsForm">
                    <div class="form-group">
                        <label class="control-label" for="detailsprojectName"><span class="asterisk">*</span>项目名:</label>
                        <input id="detailsprojectName" type="text" class="form-control" name="projectName" placeholder="输入项目名" minlength="1" disabled>
                        <div class="help-block with-errors"></div>
                    </div>
                    <div class="form-group">
                        <label class="control-label" for="detailsstrStartTime"><span class="asterisk">*</span>开始时间:</label>
                        <input type="text" class="form-control" name="strStartTime"  id="detailsstrStartTime" disabled>
                        <div class="help-block with-errors"></div>
                    </div>
                    <div class="form-group">
                        <label class="control-label" for="detailsstrEndTime"><span class="asterisk">*</span>结束时间:</label>
                        <input type="text" class="form-control" name="strEndTime"  id="detailsstrEndTime" disabled>
                        <div class="help-block with-errors"></div>
                    </div>
                    <div class="form-group">
                        <label class="control-label" for="detailscustomer"><span class="asterisk">*</span>客户:</label>
                        <input id="detailscustomer" type="text" class="form-control" name="customer" placeholder="输入客户" minlength="1" disabled>
                        <div class="help-block with-errors"></div>
                    </div>
                    <div class="form-group">
                        <label class="control-label" for="detailshead"><span class="asterisk">*</span>负责人:</label>
                        <input id="detailshead" type="text" class="form-control" name="head" placeholder="输入负责人" minlength="1" disabled>
                        <div class="help-block with-errors"></div>
                    </div>
                    <div class="form-group">
                        <label class="control-label" for="detailsparticipants"><span class="asterisk">*</span>参与人员:</label>
                        <textarea id="detailsparticipants" name="participants" class="form-control" cols="50" rows="3" placeholder="输入参与人员" disabled></textarea>
                        <div class="help-block with-errors"></div>
                    </div>
                    <div class="form-group">
                        <label class="control-label" for="detailscreateTime"><span class="asterisk">*</span>创建时间:</label>
                        <input type="text" class="form-control" name="createTime"  id="detailscreateTime" disabled>
                        <div class="help-block with-errors"></div>
                    </div>
                    <div class="form-group">
                        <label class="control-label" ><span class="asterisk">*</span>是否已经完成:</label>
                        是<input type="radio"  name="isComplete" id="detailsisComplete" value="1">
                        否<input type="radio" name="isComplete" id="detailsisComplete1" value="0" checked>
                        <div class="help-block with-errors"></div>
                    </div>
                    <div class="form-group">
                        <label class="control-label" for="detailsremark">备注:</label>
                        <textarea id="detailsremark" name="remark" class="form-control" cols="100" rows="5" placeholder="输入备注" disabled></textarea>
                        <div class="help-block with-errors"></div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>

<!-- delete Modal -->
<div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="deleteSmallModalLabel">
    <div class="modal-dialog modal-sm" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="deleteSmallModalLabel">删除项目负责信息</h4>
            </div>
            <div class="modal-body">
                <form id="deleteForm"></form>
                确定要删除选中的 <span class="records"></span> 条记录?
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" form="deleteForm" class="btn btn-primary"
                        data-action="{type:'submit',form:'#deleteForm',url:'@{/projectmanagement/delete-batch}',after:'$.myAction.refreshTable'}">
                    确定
                </button>
            </div>
        </div>
    </div>
</div>
<div id="actionButtons" class="admin-hide">
    <a class="like" href="javascript:void(0)" data-toggle="tooltip" title="详情"><i class="glyphicon glyphicon-heart"></i></a>
    <a shiro:hasPermission="projectmanagement:update" class="edit ml10" href="javascript:void(0)" data-toggle="tooltip" title="编辑"><i class="glyphicon glyphicon-edit"></i></a>　
    <a shiro:hasPermission="projectmanagement:delete" class="remove ml10" href="javascript:void(0)" data-toggle="tooltip" title="删除"><i class="glyphicon glyphicon-remove"></i></a>　
</div>
<!-- zTree -->
<div id="menuContent" class="menuContent"
     style="display:none;z-index:1989101600;position: absolute;border: 1px solid #ccc; background-color: #fff;">
    <ul id="tree" class="ztree"></ul>
</div>
<script th:inline="javascript">

    var $table = $('#table');

    $(function () {
        //Date range picker
        var beginTimeTake;
        $('#searchreservation').daterangepicker({
            "timePicker": false,
            "timePicker24Hour": true,
            "linkedCalendars": false,
            "autoUpdateInput": false,
            "locale": {
                format: 'YYYY-MM-DD',
                separator: ' ~ ',
                applyLabel: "应用",
                cancelLabel: "取消",
                resetLabel: "重置",
                daysOfWeek: ["日", "一", "二", "三", "四", "五", "六"],
                monthNames: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
            }
        }, function (start, end, label) {
            if (!this.startDate) {
                this.element.val('');
            } else {
                $('#searchstrStartTime').val(this.startDate.format(this.locale.format));
                $('#searchstrEndTime').val(this.endDate.format(this.locale.format));
                this.element.val(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
            }
        });

        //Date range picker
        var beginTimeTake;
        $('#searchreservation1').daterangepicker({
            "timePicker": false,
            "timePicker24Hour": true,
            "linkedCalendars": false,
            "autoUpdateInput": false,
            "locale": {
                format: 'YYYY-MM-DD',
                separator: ' ~ ',
                applyLabel: "应用",
                cancelLabel: "取消",
                resetLabel: "重置",
                daysOfWeek: ["日", "一", "二", "三", "四", "五", "六"],
                monthNames: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
            }
        }, function (start, end, label) {
            if (!this.startDate) {
                this.element.val('');
            } else {
                $('#searchstreStartTime').val(this.startDate.format(this.locale.format));
                $('#searchstreEndTime').val(this.endDate.format(this.locale.format));
                this.element.val(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
            }
        });

        var minDate = null;
        var max = null;
        function fromDate(maxDate) {
            if(!maxDate){
                max = moment(new Date())
            }else{
                max = maxDate;
            }
            $('#strStartTime').daterangepicker({
                "autoApply": true, //选择日期后自动提交;只有在不显示时间的时候起作用timePicker:false
                singleDatePicker: true, //单日历
                showDropdowns: true, //年月份下拉框
                timePicker: true, //显示时间
                timePicker24Hour: true, //时间制
                timePickerSeconds: true, //时间显示到秒
                // startDate: moment().hours(0).minutes(0).seconds(0), //设置开始日期
                "opens": "center",
                showWeekNumbers: true,
                locale: {
                    format: "YYYY-MM-DD HH:mm:ss", //设置显示格式
                    applyLabel: '确定', //确定按钮文本
                    cancelLabel: '取消', //取消按钮文本
                    daysOfWeek: ['日', '一', '二', '三', '四', '五', '六'],
                    monthNames: ['一月', '二月', '三月', '四月', '五月', '六月',
                        '七月', '八月', '九月', '十月', '十一月', '十二月'
                    ],
                    firstDay: 1
                },
            }, function(s) {
                toDate(s);
            });
        }
        fromDate()
        function toDate(minDate) {
            $('#strEndTime').daterangepicker({
                "autoApply": true, //选择日期后自动提交;只有在不显示时间的时候起作用timePicker:false
                singleDatePicker: true, //单日历
                showDropdowns: true, //年月份下拉框
                timePicker: true, //显示时间
                timePicker24Hour: true, //时间制
                timePickerSeconds: true, //时间显示到秒
                // startDate: moment().hours(0).minutes(0).seconds(0), //设置开始日期
                minDate: minDate,
                "opens": "center",
                showWeekNumbers: true,
                locale: {
                    format: "YYYY-MM-DD HH:mm:ss", //设置显示格式
                    applyLabel: '确定', //确定按钮文本
                    cancelLabel: '取消', //取消按钮文本
                    daysOfWeek: ['日', '一', '二', '三', '四', '五', '六'],
                    monthNames: ['一月', '二月', '三月', '四月', '五月', '六月',
                        '七月', '八月', '九月', '十月', '十一月', '十二月'
                    ],
                    firstDay: 1
                },
            }, function(s) {
                fromDate(s)
            });
        }
        toDate();

        //修改
        var  eminDate = null;
        var emax = null;
        function efromDate(emax) {
            if(!emax){
                emax = moment(new Date())
            }else{
                emax = emax;
            }
            $('#editstrStartTime').daterangepicker({
                "autoApply": true, //选择日期后自动提交;只有在不显示时间的时候起作用timePicker:false
                singleDatePicker: true, //单日历
                showDropdowns: true, //年月份下拉框
                timePicker: true, //显示时间
                timePicker24Hour: true, //时间制
                timePickerSeconds: true, //时间显示到秒
                // startDate: moment().hours(0).minutes(0).seconds(0), //设置开始日期
                "opens": "center",
                showWeekNumbers: true,
                locale: {
                    format: "YYYY-MM-DD HH:mm:ss", //设置显示格式
                    applyLabel: '确定', //确定按钮文本
                    cancelLabel: '取消', //取消按钮文本
                    daysOfWeek: ['日', '一', '二', '三', '四', '五', '六'],
                    monthNames: ['一月', '二月', '三月', '四月', '五月', '六月',
                        '七月', '八月', '九月', '十月', '十一月', '十二月'
                    ],
                    firstDay: 1
                },
            }, function(s) {
                etoDate(s);
            });
        }
        efromDate()
        function etoDate(eminDate) {
            $('#editstrEndTime').daterangepicker({
                "autoApply": true, //选择日期后自动提交;只有在不显示时间的时候起作用timePicker:false
                singleDatePicker: true, //单日历
                showDropdowns: true, //年月份下拉框
                timePicker: true, //显示时间
                timePicker24Hour: true, //时间制
                timePickerSeconds: true, //时间显示到秒
                // startDate: moment().hours(0).minutes(0).seconds(0), //设置开始日期
                minDate: minDate,
                "opens": "center",
                showWeekNumbers: true,
                locale: {
                    format: "YYYY-MM-DD HH:mm:ss", //设置显示格式
                    applyLabel: '确定', //确定按钮文本
                    cancelLabel: '取消', //取消按钮文本
                    daysOfWeek: ['日', '一', '二', '三', '四', '五', '六'],
                    monthNames: ['一月', '二月', '三月', '四月', '五月', '六月',
                        '七月', '八月', '九月', '十月', '十一月', '十二月'
                    ],
                    firstDay: 1
                },
            }, function(s) {
                efromDate(s)
            });
        }
        etoDate();
        // bootstrap table初始化
        // http://bootstrap-table.wenzhixin.net.cn/zh-cn/documentation/
        $table.bootstrapTable({
            url: CONTEXT_PATH + '/projectmanagement/selectlist',
            idField: 'id',
            columns: [
                {field: 'state', checkbox: true},
                {field: 'id', title: '编号', sortable: false, halign: 'left'},
                {field: 'projectName', title: '项目名', sortable: false, halign: 'left',
                    formatter:function(value,row,index){
                        return '<div style="color:#0000FF">' + value + '</div>';
                    }},
                {field: 'customer', title: '客户', sortable: false, halign: 'left'},
                {field: 'head', title: '负责人', sortable: false, halign: 'left'},
                {field: 'participants', title: '参与人员', sortable: false, halign: 'left'},
                {field: 'startTime', title: '开始时间', sortable: false, halign: 'left'},
                {field: 'endTime', title: '结束时间', sortable: false, halign: 'left'},
                {field: 'isComplete', title: '是否完成', sortable: false, halign: 'left',
                    formatter:function(value,row,index){
                        if (value == "1") { return '<div >' + '已完成' + '</div>'; }
                        else if(value == "0") { return '<div style="color:#F00">' + '未完成' + '</div>';  }

                    }
                },
                {
                    field: 'action',
                    title: '操作',
                    halign: 'center',
                    align: 'center',
                    formatter: 'actionFormatter',
                    events: 'actionEvents',
                    clickToSelect: false
                }
            ]
        });
    });
    // 数据表格展开内容
    function detailFormatter(index, row) {
        var html = [];
        $.each(row, function (key, value) {
            if (key=='remark') {
                html.push('<p><b>' + '备注' + ':</b> ' + value + '</p>');
            }
        });
        return html.join('');
    }

    function actionFormatter(value, row, index) {
        return $('#actionButtons').html();
    }

    function cej(){
        $("#searchstrStartTime").val("");
        $("#searchstrEndTime").val("");
        $("#searchstreStartTime").val(CurentTime(0));
        $("#searchstreEndTime").val(CurentTime(1));
        $("#searchreservation").val("");
        $("#searchreservation1").val("");
    }

    function txtclear(){
        var text=document.getElementById("searchreservation").value;//通过id获取需要验证的表单元素的值
        var text1=document.getElementById("searchreservation1").value;
        if(text==""){//当上面获取的值为空时
            document.getElementById("searchstrStartTime").value="";
            document.getElementById("searchstrEndTime").value="";
        }
        if(text1==""){//当上面获取的值为空时
            document.getElementById("searchstreStartTime").value="";
            document.getElementById("searchstreEndTime").value="";
        }
    }

    window.actionEvents = {
        'click .edit': function (e, value, row, index) {
            $('#editModal').modal('show')
            $('#editForm').fillForm(row);
            $('#editForm [name="strStartTime"]').val(row.startTime);
            $('#editForm [name="strEndTime"]').val(row.endTime);
            console.log(value, row, index);
        },
        'click .like': function (e, value, row, index) {
            $('#detailsModal').modal('show');
            $('#detailsForm').fillForm(row);
            $('#detailsForm [name="strStartTime"]').val(row.startTime);
            $('#detailsForm [name="strEndTime"]').val(row.endTime);
            console.log(value, row, index);
        },
        'click .remove': function (e, value, row, index) {
            $('#deleteModal').modal('show');
            $('.records').html('1');
            var html = '';
            for (var key in row) {
                html += '<input type="hidden" name="' + key + '" value="' + row[key] + '">';
            }
            $('#deleteForm').html(html);
        }
    };

    function editAfter(obj, row) {
        $('#editForm [name="strStartTime"]').val(row.startTime);
        $('#editForm [name="strEndTime"]').val(row.endTime);
    }

    function CurentTime(fmt){

        var now = new Date();
        if (fmt==1){
            var year = now.getFullYear()+1; //年
        }else {
            var year = now.getFullYear(); //年
        }
        var month = now.getMonth() + 1; //月
        var day = now.getDate(); //日

        var hh = now.getHours(); //时
        var mm = now.getMinutes(); //分
        var ss = now.getSeconds(); //秒

        var clock = year + "-";

        if(month < 10)
            clock += "0";

        clock += month + "-";

        if(day < 10)
            clock += "0";

        clock += day + " ";

        return(clock);
    }


    //获取当前的时间
    Date.prototype.Format = function (fmt) {
        var o = {
            "M+": this.getMonth() + 1, //月份
            "d+": this.getDate(), //日
            "H+": this.getHours(), //小时
            "m+": this.getMinutes(), //分
            "s+": this.getSeconds(), //秒
            "q+": Math.floor((this.getMonth() + 3) / 3), //季度
            "S": this.getMilliseconds() //毫秒
        };
        if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
            if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        return fmt;
    }

</script>
</html>